import cookie$1 from 'cookie';

const getAllCookies = () => {
    const cookies = cookie$1.parse(document.cookie);
    return cookies;
};
const getCookie = (name) => {
    const cookies = cookie$1.parse(document.cookie);
    const value = cookies && cookies[name];
    if (value) {
        const hasToParse = Boolean((value && value[0] === '{') || value[0] === '[');
        return hasToParse ? JSON.parse(value) : value;
    }
    return null;
};
const removeCookie = (name) => {
    const options = { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 };
    document.cookie = cookie$1.serialize(name, '', options);
    return document.cookie;
};
const setCookie = (name, value, options = {}) => {
    const rawCookie = {};
    rawCookie[name] = value;
    if (typeof value === 'object') {
        rawCookie[name] = JSON.stringify(value);
    }
    document.cookie = cookie$1.serialize(name, rawCookie[name], options);
    return document.cookie;
};
var cookie = {
    getAllCookies,
    getCookie,
    removeCookie,
    setCookie
};

export { cookie as default };
